<div class="layui-container fly-marginTop fly-user-main">
  {include file="common/menu"}

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>


  <div class="fly-panel fly-panel-user" pad20>
    <!--
    <div class="fly-msg" style="margin-top: 15px;">
      您的邮箱尚未验证，这比较影响您的帐号安全，<a href="activate.html">立即去激活？</a>
    </div>
    -->
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li data-type="collection" data-url="/collection/find/" class="layui-this" lay-id="collection">
          我收藏的帖（<span>{$collectCount}</span>）</li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <ul class="mine-view jie-row">
            {foreach $postList as $item}
            <li>
              <a class="jie-title" href="../jie/detail.html" target="_blank">{$item['title']}</a>
              <i>{$item['createtime']}</i>
              <span style="float: right;" class="layui-btn layui-btn-xs jie-admin layui-bg-blue" type="edit"
                onclick="delone(`{$item['id']}`)">
                取消收藏
              </span>
            </li>
            {/foreach}
          </ul>
          <div id="LAY_page1"></div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  function delone(id) {
    var postId = id;

    console.log(postId);

    layui.use('layer', function () {
      var layer = layui.layer
      var $ = layui.jquery


      $.ajax({
        type: "POST",
        url: `{:url('home/collect/del')}`,
        data: {
          postid: postId,
        },
        dataType: "json",
        success: function (data) {
          if (data.result) {
            // 成功
            layer.msg(data.msg, {
              icon: 1,
              time: 2000,
            }, function () {
              // 收藏成功刷新界面
              location.reload();
            })
          } else {
            // 失败
            layer.msg(data.msg);
          }
        }
      })
    })
  }


</script>